class Solution
{
public:
    long long maxKelements(vector<int> &nums, int k)
    {
        priority_queue<int> q(nums.begin(), nums.end());
        long long result = 0;
        for (int i = 0; i < k; ++i)
        {
            int val = q.top();
            q.pop();
            result += val;
            q.push(ceil(val / 3.0));
        }
        return result;
    }
};